<template>
    <div class="page-appointment-success">
      <div class="info">
        <div class="icon">
          <van-icon :name="result.icon" size="48" :class="result.payState == '0' ? 'c-red' : 'c-blue'" />
        </div>
        <div class="title">
          <h3>{{ result.title }}</h3>
        </div>
        <!-- <div class="desc m-b-10">
          您已预约成功，请您持本人就诊卡/身份证
        </div>
        <div class="desc">
          按时就诊
        </div> -->
      </div>
      <div class="p-a-15">
        <van-button type="default" block @click="$util.gotoPage('/')">返回首页</van-button>
      </div>
  
    </div>
  </template>
  <script>
  export default {
    data(){
      return {
        pageParams:{
          
        },
        result:{
          payState: '1',
          icon: 'checked',
          title: '支付成功',
        }
      }
    },
    created(){
      this.pageParams = this.$route.query;
      this.getResult();
    },
    methods:{
        handlePopState(){
            this.$util.gotoPage('/');
        },
        getResult(){
          this.$http('get', '/admin/billPayment/'+this.pageParams.payId, {}, (data,msg) => {
            // this.$dialog.alert({
            //   // message: JSON.stringify(data)
            //   message: data.payState
            // }).then(() => {

            // });
            this.result.payState = data.payState;
            if(data.payState == '0'){              
              this.result.icon = 'clear';
              this.result.title = '支付取消';
            }else if(data.payState == '1'){
              this.result.icon = 'checked';
              this.result.title = '支付成功';
            }
          });
        }
    },
    mounted() {
        window.addEventListener('popstate', this.handlePopState);
    },
    beforeDestroy() {
        window.removeEventListener('popstate', this.handlePopState);
    },
  }
  </script>